package cn.tedu.search.entity;
//商品类

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

@Data
@Accessors(chain = true)
//生成全参构造
@AllArgsConstructor
//生成无参构造
@NoArgsConstructor
//对应ES索引名称,当操作这个索引时,如果索引不存在,会自动创建这个索引
@Document(indexName = "items")
public class Item implements Serializable {
    //商品id
    @Id  //SpringData标记当前索引主键的注解@Id
    private Long id;

    //商品名称
    //SpringData使用@Field标记文档中的属性的类型和各种特征
    @Field(type = FieldType.Text,
    analyzer = "ik_max_word",
    searchAnalyzer = "ik_max_word")
    private String title;
    //分类
    //Keyword不分词的字符串
    @Field(type = FieldType.Keyword)
    private String category;
    //品牌
    @Field(type = FieldType.Keyword)
    private String brand;
    //价格
    @Field(type = FieldType.Double)
    private Double price;
    //图片地址
    //图片地址不会成为搜索条件,所以设置index = false
    //所以不需要将图片地址也创建索引表,能节省空间
    @Field(type = FieldType.Keyword,index = false)
    private String imgPath;


}
